﻿Imports System.Collections.Generic
Imports DomusDotNet.Sbm.Services
Imports DomusDotNet.Sbm.Services.Interfaces
Imports System
Imports Microsoft.VisualStudio.TestTools.UnitTesting
Imports DomusDotNet.Sbm.Services.Implementations


Namespace DomusDotNet.Sbm.Wcf.Test
    '''<summary>
    '''This is a test class for FakeAuthenticationServiceTest and is intended
    '''to contain all FakeAuthenticationServiceTest Unit Tests
    '''</summary>
    <TestClass()> _
    Public Class FakeAuthenticationServiceTest


        Private testContextInstance As TestContext

        '''<summary>
        '''Gets or sets the test context which provides
        '''information about and functionality for the current test run.
        '''</summary>
        Public Property TestContext() As TestContext
            Get
                Return testContextInstance
            End Get
            Set(value As TestContext)
                testContextInstance = value
            End Set
        End Property

#Region "Additional test attributes"
        '
        'You can use the following additional attributes as you write your tests:
        '
        'Use ClassInitialize to run code before running the first test in the class
        '<ClassInitialize()>  _
        'Public Shared Sub MyClassInitialize(ByVal testContext As TestContext)
        'End Sub
        '
        'Use ClassCleanup to run code after all tests in a class have run
        '<ClassCleanup()>  _
        'Public Shared Sub MyClassCleanup()
        'End Sub
        '
        'Use TestInitialize to run code before running each test
        '<TestInitialize()>  _
        'Public Sub MyTestInitialize()
        'End Sub
        '
        'Use TestCleanup to run code after each test has run
        '<TestCleanup()>  _
        'Public Sub MyTestCleanup()
        'End Sub
        '
#End Region


        '''<summary>
        '''A test for FakeAuthenticationService Constructor
        '''</summary>
        <TestMethod()> _
        Public Sub FakeAuthenticationServiceConstructor()
            Dim target As FakeAuthenticationService = New FakeAuthenticationService()
            Assert.IsNotNull(target)
        End Sub

        '''<summary>
        '''A test for ValidateUser
        '''</summary>
        <TestMethod()> _
        Public Sub ValidateUser_ValidUser()
            Dim target As IAuthenticationService = New FakeAuthenticationService()
            Dim username As String = "username"
            Dim password As String = "username"
            Dim expected As Boolean = True
            Dim actual As Boolean
            actual = target.ValidateUser(username, password)
            Assert.AreEqual(expected, actual)
            Assert.IsTrue(target.Errors.Count = 0)
        End Sub

        <TestMethod()> _
        Public Sub ValidateUser_UnknownUser()
            Dim target As IAuthenticationService = New FakeAuthenticationService()
            Dim username As String = "username"
            Dim password As String = "password"
            Dim expected As Boolean = False
            Dim actual As Boolean
            actual = target.ValidateUser(username, password)
            Assert.AreEqual(expected, actual)
            Assert.IsTrue(target.Errors.Count > 0)
        End Sub

        <TestMethod()> _
        Public Sub ValidateUser_EmptyUsername()
            Dim target As IAuthenticationService = New FakeAuthenticationService()
            Dim username As String = String.Empty
            Dim password As String = "password"
            Dim expected As Boolean = False
            Dim actual As Boolean
            actual = target.ValidateUser(username, password)
            Assert.AreEqual(expected, actual)
            Assert.IsTrue(target.Errors.Count > 0)
        End Sub

        <TestMethod()> _
        Public Sub ValidateUser_EmptyPassword()
            Dim target As IAuthenticationService = New FakeAuthenticationService()
            Dim username As String = "username"
            Dim password As String = String.Empty
            Dim expected As Boolean = False
            Dim actual As Boolean
            actual = target.ValidateUser(username, password)
            Assert.AreEqual(expected, actual)
            Assert.IsTrue(target.Errors.Count > 0)
        End Sub

        <TestMethod()> _
        Public Sub ValidateUser_EmptyUsernameAndPassword()
            Dim target As IAuthenticationService = New FakeAuthenticationService()
            Dim username As String = String.Empty
            Dim password As String = String.Empty
            Dim expected As Boolean = False
            Dim actual As Boolean
            actual = target.ValidateUser(username, password)
            Assert.AreEqual(expected, actual)
            Assert.IsTrue(target.Errors.Count > 0)
        End Sub

        <TestMethod()> _
        Public Sub ValidateSessionGuid_ValidGuid()
            Dim target As IAuthenticationService = New FakeAuthenticationService()
            Dim guid As String = System.Guid.NewGuid.ToString()
            Dim expected As Boolean = True
            Dim actual As Boolean
            actual = target.ValidateSessionGuid(guid)
            Assert.AreEqual(expected, actual)
            Assert.IsTrue(target.Errors.Count = 0)
        End Sub

        <TestMethod()> _
        Public Sub ValidateSessionGuid_EmptyGuid()
            Dim target As IAuthenticationService = New FakeAuthenticationService()
            Dim guid As String = String.Empty
            Dim expected As Boolean = False
            Dim actual As Boolean
            actual = target.ValidateSessionGuid(guid)
            Assert.AreEqual(expected, actual)
            Assert.IsTrue(target.Errors.Count > 0)
        End Sub

        <TestMethod()> _
        Public Sub ValidateSessionGuid_NotValidGuid()
            Dim target As IAuthenticationService = New FakeAuthenticationService()
            Dim guid As String = "aaa"
            Dim expected As Boolean = False
            Dim actual As Boolean
            actual = target.ValidateSessionGuid(guid)
            Assert.AreEqual(expected, actual)
            Assert.IsTrue(target.Errors.Count > 0)
        End Sub

    End Class
End Namespace